<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/bank.js"></script>
<style type="text/css">
	.city-box {
		height:460px;
		width:385px;
		overflow-y:scroll;
		overflow-x:hidden;
		box-sizing:border-box;
		-webkit-box-sizing:border-box;
		-moz-box-sizing:border-box;
	}
	
	.city-box {
		border-right:0;
	}
	
	.city-box dt,.city-box dd {
		line-height:22px;
	}
	.city-box>dl>dd {
		padding-left:18px;
	}
	.city-box input[type="checkbox"] {
		vertical-align:sub;
		margin-right:5px;
	}
	
	.city-box>dl>dd>dl>dd {
		padding-left:38px;
	}
	.black_overlay{
		display: none;
		position: absolute;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index:1001;
		-moz-opacity: 0.8;
		opacity:.80;
		filter: alpha(opacity=80);
	}
	.white_content {
		display: none;
		position: absolute;
		top: 35%;
		left: 25%;
		width: 40%;
		height:7%;
		border: 5px double rgb(204,217,232);
		background-color: white;
		z-index:1002;
		overflow: auto;
		text-align:center;
		font-size:15px;
		line-height:35px;
	}
</style>
<div id="fade" class="black_overlay">
</div>
<div id="MyDiv" class="white_content">
刷新中,请等待。
</div>
<form action="/branch/unadmittance/option/unadmittancesave/" method="post" name="form1" class="J-ajaxForm" id="form1">
<input type="hidden" name="br_id" value="<?php echo $this->br_id;?>" />
<div class="city-box J-city-box-h J-city-list" id="edit" style="display:none">
    	<?php
			if(!empty($this->all_data['province'])) foreach($this->all_data['province'] as $ok => $ov){
		?>
        <dl>
        	<dt><em class="ico-arrows J-ico-arrows"></em>&nbsp;<em class="ico-folder-open"></em>&nbsp;<input type="checkbox" name="place_id[]" value="<?php echo $ov['id'];?>" <?php $arr1 = explode(',',$ov['unadmittance_branch']);if(in_array($this->br_id,$arr1)){echo 'checked="checked"';}?>/><?php echo $ov['city'];?></dt></dt>
            <dd class="J-one fn-hide">
				<?php
					if(!empty($this->all_data['city'][$ov['city']])) foreach($this->all_data['city'][$ov['city']] as $sk => $sv){
				?>
            	<dl>
                	<dt>
                    	<?php
                        	if(empty($this->all_data['area'][$sv['city']])){
						?>
                    		<em class="ico-leaf"></em>&nbsp;
                        <?php
							}else{
						?>
                    		<em class="ico-arrows J-ico-arrows"></em>&nbsp;<em class="ico-folder-open"></em>&nbsp;
                        <?php
							}
						?>
                        <input type="checkbox" name="place_id[]" value="<?php echo $sv['id'];?>" class="J-solo" <?php $arr2 = explode(',',$sv['unadmittance_branch']);if(in_array($this->br_id,$arr2)){echo 'checked="checked"';}?>/><?php echo $sv['city'];?>
                    </dt>
                    
                    <dd class="J-parent fn-hide">
                    	<dl>
							<?php
								if(!empty($this->all_data['area'][$sv['city']])) foreach($this->all_data['area'][$sv['city']] as $tk => $tv){
							?>
                        	<dd><em class="ico-leaf"></em>&nbsp;<input type="checkbox" class="J-srole" name="place_id[]" value="<?php echo $tv['id'];?>"  <?php $arr3 = explode(',',$tv['unadmittance_branch']);if(in_array($this->br_id,$arr3)){echo 'checked="checked"';}?>/><?php echo $tv['city'];?></dd>
							<?php
								}
							?>
                        </dl>
                    </dd>
                </dl>
				<?php
					}
				?>
            </dd>
        </dl>
		<?php
			}
		?>
</div>
<div class="city-box J-city-box-h J-city-list" id="list">
    	<?php
			if(!empty($this->unadmit_data['province'])){ foreach($this->unadmit_data['province'] as $ok => $ov){
		?>
        <dl>
        	<dt><em class="ico-arrows-on on J-ico-arrows"></em>&nbsp;<em class="ico-folder-open"></em>&nbsp;<?php echo $ov['city'];?></dt>
            <dd class="J-one">
				<?php
					if(!empty($this->unadmit_data['city'][$ov['city']])) foreach($this->unadmit_data['city'][$ov['city']] as $sk => $sv){
				?>
            	<dl>
                	<dt>
                    	<?php
                        	if(empty($this->unadmit_data['area'][$sv['city']])){
						?>
                    		<em class="ico-leaf"></em>&nbsp;
                        <?php
							}else{
						?>
                    		<em class="ico-arrows-on on J-ico-arrows"></em>&nbsp;<em class="ico-folder-open"></em>&nbsp;
                        <?php
							}
						?>
                        <?php echo $sv['city'];?>
                    </dt>
                    
                    <dd class="J-parent">
                    	<dl>
							<?php
								if(!empty($this->unadmit_data['area'][$sv['city']])) foreach($this->unadmit_data['area'][$sv['city']] as $tk => $tv){
							?>
                        	<dd><em class="ico-leaf"></em>&nbsp;<?php echo $tv['city'];?></dd>
							<?php
								}
							?>
                        </dl>
                    </dd>
                </dl>
				<?php
					}
				?>
            </dd>
        </dl>
		<?php
			}}else{
		?>
		<h1 style="color:red;">暂无准入地区,点击编辑按钮后,勾选添加准入地区</h1>
	<?php }?>
</div>
<div style="position:fixed; bottom:0; width:100%; left:0; background:#FFF; text-align:right; padding:10px 20px; box-sizing:border-box; -webkit-box-sizing:border-box; -moz-box-sizing:border-box;">
		<a href="" class="a-btn-close J-a-btn-edit fn-right">编辑</a>
        <input type="submit" class="J-submit btn-submit-blue mr10" style="display: none" id='save' value="保存修改" />
	</div>
</form>
<script type="text/javascript">
	$(document).ready(function(e) {
        $(".J-submit").on('click',function(){
			$(this).dyhlForm({
				beforefunction:btnSubmitChk,
				nofunction:function(){
					$(".J-submit").prop('disabled',false);
					Ext.getBody().unmask();
				},
				sucessfunction:function(data){
					$(".J-submit").prop('disabled',false);
					Ext.getBody().unmask();
					if(data['success']){
						Ext.Msg.alert('提示','提交成功',function(){
							window.location.reload();
							ShowDiv('MyDiv','fade');
						});
						//window.location.reload();
					}else{
						Ext.Msg.alert('提示',data['msg']);
					}
				}	
			});	
		});
    });

	function btnSubmitChk(){
		Ext.getBody().mask("数据提交中，请稍等");		
	}; 

	function ShowDiv(show_div,bg_div){
		document.getElementById(show_div).style.display='block';
		document.getElementById(bg_div).style.display='block' ;
		var bgdiv = document.getElementById(bg_div);
		bgdiv.style.width = document.body.scrollWidth;
		$("#"+bg_div).height($(document).height());
	};

	$(".J-city-box-h").on('click','.J-ico-arrows',function(){
		if($(this).hasClass('on')){
			$(this).addClass("ico-arrows").removeClass("ico-arrows-on");
			$(this).closest('dt').siblings('dd').addClass('fn-hide');
			$(this).removeClass('on');	
		}else{
			$(this).addClass("ico-arrows-on").removeClass("ico-arrows");
			$(this).closest('dt').siblings('dd').removeClass('fn-hide');
			$(this).addClass('on');	
		}	
	});
	
	//菜单全选、取消
	$(".J-city-box-h").on('change','input[type="checkbox"]',function(){
		$(this).closest('dt').siblings('dd').find('input[type="checkbox"]').prop('checked',$(this).prop("checked"));	
	});
	
	//三级选中
	$(".J-city-box-h").on('change','.J-srole',function(){
		$(this).closest('.J-parent').siblings('dt').find('input[type="checkbox"]').prop('checked',true);
		$(this).closest('.J-one').siblings('dt').find('input[type="checkbox"]').prop('checked',true);
	});
	$(".J-city-box-h").on('change','.J-solo',function(){
		$(this).closest('.J-parent').siblings('dt').find('input[type="checkbox"]').prop('checked',true);
		$(this).closest('.J-one').siblings('dt').find('input[type="checkbox"]').prop('checked',true);
	});


	$(".J-a-btn-edit").on('click',function(){
		if($(this).text() =='编辑'){
			$(this).text('放弃此次编辑');
			$("#save").attr("style","display:block;"); 
		}else{
			$(this).text('编辑');
			$("#save").attr("style","display:none;");  
		}
		$("#edit").toggle();
		$("#list").toggle();
		if($(this).text() =='编辑'){
			if(window.confirm('是否放弃本次编辑并刷新？点击取消保留此次修改，但不提交')){
				window.location.href='/branch/unadmittance/option/unadmittancelist?id='+<?php echo $this->br_id;?>;
				ShowDiv('MyDiv','fade');
			}
		}
		return false;
	});
	</script>
<?php include $this->Render('footer.php'); ?>